package
{
	import flash.display.Bitmap;
	import flash.display.Stage;
	import flash.display.StageAlign;
	
	import widget.dining.manager.BitmapEmbedManager;
	import widget.dining.mode.DinnerVO;

	public class WidgetOrderDinner extends WidgetMain{
		public static const TYPE_FOOD:String = "food";
		public static const TYPE_DRINK:String = "drink";
	
		private var itemList:Vector.<DinnerVO> = null;
		private var generaList:Vector.<DinnerVO> = null;
		
		private var bgBitmap:Bitmap = null;
		public function WidgetOrderDinner()
		{
			super();
		}
		
		protected override function init():void
		{
			stage.align = StageAlign.TOP_LEFT;
			itemList = new Vector.<DinnerVO>();
			generaList = new Vector.<DinnerVO>();
			configPath = "resource/config/orderdinner.xml";
			loadXMLConfig();
			BitmapEmbedManager.getInstance();
			create();
		}
		
		
		protected override function parseConfigXML(xmlStr:String):void
		{
			if(xmlStr == "") return;
			var xmlDoc:XML = new XML(xmlStr);
			var generaXMLList:XMLList = xmlDoc.child("generas/genera");
			var itemXMLList:XMLList = xmlDoc.child("items/item");
			var i:uint = 0;
			var leng:int = generaXMLList.length();
			for(i = 0;i < leng;i++){
				var generaVO:DinnerVO = new DinnerVO();
				generaVO.id = String(generaXMLList[i].attribute("id"));
				generaVO.genera = String(generaXMLList[i].attribute("genera"));
				generaVO.icon = String(generaXMLList[i].attribute("icon"));
				generaList.push(generaVO);
			}
			leng = itemXMLList.length();
			for(i = 0;i < leng;i++){
				var itemVO:DinnerVO = new DinnerVO();
				itemVO.price = Number(generaXMLList[i].attribute("price"));
				itemVO.name = String(generaXMLList[i].attribute("name"));
				itemVO.genera = String(generaXMLList[i].attribute("genera"));
				itemVO.icon = String(generaXMLList[i].attribute("icon"));
				itemList.push(itemVO);
			}
		}
		
		private function create():void
		{
			bgBitmap = BitmapEmbedManager.getInstance().dinnerBG;
			bgBitmap.x = 0;
			bgBitmap.y = 0;
			this.addChild(bgBitmap);
		}
	}
}